﻿//TODO: test, TextureGenerator

using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// 
    /// </summary>
    public class TextureGenerator : BaseImageFilter
    {
        protected ITextureCreator m_TextureCreator = null;

        /// <summary>
        /// Initializes a new instance of the <see cref="TextureGenerator"/> class.
        /// </summary>
        public TextureGenerator(ITextureCreator _textureCreator)
        {
            m_TextureCreator = _textureCreator;
        }

        /// <summary>
        /// Used to create a deep copy
        /// </summary>
        /// <param name="_textureGenerator"></param>
        internal TextureGenerator(TextureGenerator _textureGenerator)
        {
            m_TextureCreator = _textureGenerator.m_TextureCreator;
        }

        /// <summary>
        /// Execute this Filter
        /// A Debug Statement is written if a concrete Filter is called
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            int nWidth = _bitmap.Width;
            int nHeight = _bitmap.Height;
            float[,] aTexture = m_TextureCreator.Create(nWidth, nHeight);

            return _bitmap;
        }

        /// <summary>
        /// This is used to clone a filter, each filter must implement it's own clone functionality
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new TextureGenerator(this);            
        }
    }
}
